#ifndef RESOURCE_H
#define RESOURCE_H

#include <conio.h>
#include <string>
#include <vector>
#include <map>

#include "ObjectTypes.h"
#include "Entity.h"
#include "Sprite.h"
#include "Text.h"
#include "CMesh.h"
#include "Texture.h"
#include "Camera.h"


typedef std::vector<Entity *> VECTOR_SPRITE;		//shortens the call into vector_sprite
typedef std::map<std::string, Entity*> MAP_SPRITE;  //shortens the call into map_sprite

class Resource
{

	private:
										///Manages all the physics on objects
		b2World * world_physics;
										///Objects that sleep or not in the world during a collision
		bool doSleep;
										///the pointer to the device class
		LPDIRECT3DDEVICE9 d3ddev;
										///Container that holds objects
		VECTOR_SPRITE vsprite_resource;
										///Container that holds objects (Helps with Retrieving Objects By Name)
		MAP_SPRITE    msprite_resource;
										///Container that holds Textures
		std::vector<Texture*> * texture_resource;
										///How many objects not culled
		int nCulled;

	public:
											///Constructor
		Resource(LPDIRECT3DDEVICE9 d3ddev);
											///Destructor
		~Resource();
													///Return Texture by surfaceID (determined by the level editor)
		Texture * GetTexture(int SurfaceId);
													///Init the pysics world
		void initPhysics(float width=10.0f, float height=10.0f, float gravity=-10.0f);
													///Add Object
		void AddObject(std::string object_name="Sprite", int object_type=SPRITE);
		void AddObject(Entity * object);
													///Add Texture
		void AddTexRes(std::string tpath, int id=0);
													///Get Object
		Entity * GetObject(std::string object_name);
													///Get Object
		Entity * GetObject(int index);
													///Number of objects
		int NumberOfObjects();
													///Renders All Objects
		void Render(Camera * camera=NULL);
													///Get Created Box2d World
		b2World * getWorldPhysics() {return world_physics;}
													///Get Number of Objects
		int TotalObjects(){return vsprite_resource.size();}
													///Get Number of Culled Objects
		int TotalCulledObjects(){return nCulled;}
};

#endif